function ajax({method, url, params, token, ContentType, callBack}){
    var xhr = new XMLHttpRequest()
    var str = ""
    // {
        // name:"张三"
    // }//name=zhangsan&age=18&
    for(var i in params){ // name（i） = "zhangsan"(params[i])&
        str += `${i}=${params[i]}&`
    }
    if (method == "get") {
        // http://wish.byesame.com/login?name=zhangsan&age=18
        xhr.open(method,url + "?"+str)
        if(token){
            xhr.setRequestHeader("token", token)
        }
        xhr.send();
    }else if(method == "getInfo"){
        var val =''
        // {
            // id:100
        // }
        // http://wish.byesame.com/admin/100
        for(var j in params){
            val = params[j]
        }
        xhr.open("get",url + "/" + val)
        if(token){
            xhr.setRequestHeader("token", token)
        }
        xhr.send()
    }else if(method == "post"){
        xhr.open(method, url)
        if(token){
            xhr.setRequestHeader("token", token)
        }
        if (ContentType == "application/x-www-form-urlencoded") {
            xhr.setRequestHeader("Content-Type",ContentType)
            // name=zhangsan&age=18
            xhr.send(str)
        }else if (ContentType == "application/json") {
            // {
                // name:zhangsan,
                // age:18
            // }
            xhr.setRequestHeader("Content-Type",ContentType)
            xhr.send(JSON.stringify(params))
        }else if(ContentType == "multipart/form-data"){
            var fd = new FormData();
            // {
                // file1：。。，
                // file2:...
            // }
            for(var k in params){
                // append(key,value)
                fd.append(k,params[k])
            }
            xhr.send(fd)
        }
    }
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4){
            callBack(xhr.responseText)
        }
    }
}